package flc.ast.adapter;


import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;

import android.graphics.Color;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.media.bean.AudioBean;
import stark.common.basic.utils.TimeUtil;

public class SelAudioAdapter extends StkProviderMultiAdapter<AudioBean> {

    public boolean hasQuery;
    public String keyWord;

    public SelAudioAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new SelAudioProvider());
    }

    private boolean isTransfer = false;

    public void setTransfer(boolean transfer) {
        isTransfer = transfer;
    }

    private class SelAudioProvider extends BaseItemProvider<AudioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_audio;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, AudioBean bean) {
            baseViewHolder.setText(R.id.tvSelAudioItemName, bean.getName());
            baseViewHolder.setText(R.id.tvSelAudioItemSize, ConvertUtils.byte2FitMemorySize(bean.getSize(), 0));
            baseViewHolder.setText(R.id.tvSelAudioItemDuration, TimeUtil.getMmss(bean.getDuration()));
            if (isTransfer) {
                baseViewHolder.getView(R.id.ivSelAudioItemEdit).setVisibility(View.GONE);
            }
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.llSelAudioItem).setBackgroundColor(Color.parseColor("#1A2D53FF"));
            } else {
                baseViewHolder.getView(R.id.llSelAudioItem).setBackgroundColor(0);
            }
        }
    }

}
